package com.apes.scm.rcl.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * 功能：日结任务处理实例
 *
 * @author xul
 * @create 2019-12-04 16:54
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = RclTaskInst.CONST_TABLE_NAME)
public class RclTaskInst extends Model {
    public static final String CONST_TABLE_NAME = "ir_rcl_task_inst";

    @Id
    @Column(name = "id", nullable = false, length = 30)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "日结任务处理实例")
    private String id;

    @Temporal(TemporalType.DATE)
    @Column(name = "task_date")
    @Comment("日结日期")
    private Date taskDate;

    @Column(name = "task_id", nullable = false, length = 30)
    @Comment("任务")
    private String task;

    @Column(name = "success", nullable = false, columnDefinition = "number(1,0) default 0")
    @Comment("是否成功")
    private boolean success = false;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "message", columnDefinition = "CLOB")
    @Comment("消息")
    private String message;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "start_date", nullable = false)
    @Comment("开始时间")
    private Date startDate;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "end_date", nullable = false)
    @Comment("结束日期")
    private Date endDate;
}
